package com.hut.oa.model.dao.scedule;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import com.hut.oa.model.bean.ScheduleManage;

public interface SceduleDao extends PagingAndSortingRepository<ScheduleManage, Long>{
	ScheduleManage findBySmId(Long id);
	
	@Query("from ScheduleManage sm where sm.smSendUserId=:id")
	Page<ScheduleManage> findBySmSendUserId(@Param("id")Long id,Pageable pageable);
	
	@Query("from ScheduleManage sm where sm.smSendUserId=:id and sm.smTitle like %:key%")
	Page<ScheduleManage> findBySmSendUserandc(@Param("id")Long id,@Param("key")String key,Pageable pageable);
	
	@Query("from ScheduleManage sm where (sm.smSendUserId=:id and sm.smTitle like %:key%) or (sm.smTitle like %:key% and sm.id in :ids)")
	Page<ScheduleManage> findbyuserandcoruid(@Param("id")Long id,@Param("key")String key,@Param("ids")List<Long> ids, Pageable pageable);
	
	@Query("from ScheduleManage sm where sm.smSendUserId=:id")
	List<ScheduleManage> findByUserId(@Param("id")Long id);
	
	@Query("from ScheduleManage sm where sm.id in :ids")
	List<ScheduleManage> findbyids(@Param("ids")List<Long> id);
	
}
